#include "../sq_stack/sq_stack.h"
#include <stdio.h>


Bool visit_char(const void *c)
{
	printf("%c",* (char*)c);
	return TRUE;
}

int main(int argc, char * argv[]){
	if(argc == 1){
		printf("Accept two arguments\n");
		printf("eg: conversion 7 2\n");
		printf("result: 111\n");
		exit(0);
	}

	int val = atoi(argv[1]);
	int j = atoi(argv[2]);
	char c;
	sq_stack s;
	sqstack_init(&s, sizeof(char));
	while(val){
		c = val % j + 48;
		push(&s, (void *) &c, sizeof(char));
		val = val / j;
	}
	while(!sqstack_empty(&s)){
		pop(&s, (void *) &c, sizeof(char));
		visit_char((void *) &c);
	}
	printf("\n");
}
